package com.erp.erp_ui.TaskInfo.controller;

import com.erp.erp_entitys.TaskInfo.entity.TaskInfo;
import com.erp.erp_servers.TaskInfo.TaskInfoService;
import com.erp.erp_ui.TaskInfo.req.AddNewupTaskReq;
import com.erp.erp_ui.TaskInfo.service.NewUpTaskService;
import com.erp.erp_ui.base.Base;
import com.erp.utils.R;
import com.erp.utils.ResultStatusEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 任务主信息表(TaskInfo)表控制层
 *
 * @author makejava
 * @since 2020-10-18 22:33:06
 */
@Controller
@RequestMapping(value = "taskInfo")
public class TaskInfoController extends Base {
    /**
     * 服务对象
     */
    private NewUpTaskService newUpTaskService;

    @Autowired
    public TaskInfoController(NewUpTaskService newUpTaskService) {
        this.newUpTaskService = newUpTaskService;
    }

    /**
     * 日志
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(TaskInfoController.class);


    /**
     * 出口业务-任务（备货合同）-新增、修改
     * @param req 新增、修改数据实体
     * @return 新增、修改结果
     */
    @PostMapping("/add/netmask")
    @ResponseBody
    public R addNewTask(@Validated @RequestBody AddNewupTaskReq req){
        LOGGER.info("出口业务-任务（备货合同）-新增、修改 req=" + req.toString());
        try {
            //UserEntity user = (UserEntity)this.getBean("user");
            //String name = user.getName();
            //String code = user.getCode();
            String name = "xq";
            String code = "xq-001";
            return newUpTaskService.add(req, name, code);

        }catch (Exception e){
            LOGGER.info("出口业务-任务（备货合同）-新增、修改：" + e);
            return R.buildError(ResultStatusEnum.SYSTEM_ERROR);
        }
    }

}